/**
 * 
 */
package org.jackysoft.data;

import java.io.Serializable;
import java.util.Collection;
import java.util.Map;

import org.jackysoft.entity.BaseOption;
import org.jackysoft.entity.Identifiable;
import org.jackysoft.entity.Optional;
import org.jackysoft.query.Query;



/**
 * This interface is inspired by a similar interface on Wicket framework...
 * 
 * @author Ernesto Reinaldo Barreiro (reirn70@gmail.com)
 *
 */
public interface IDataProvider<ID extends Serializable,B extends Identifiable> extends Serializable,CRUDDataProvider<ID,B> {
		
	/**
	 * Returns an Iterable over the records starting at first and ending at first+size.
	 * 
	 * @param start first record to return
	 * @param size number of records to return
	 * @param searchBean Bean to be used for filtering the results.
	 * @param sortInfo  which column should be used for ordering data.
	 * @param searchFields Which fields of the seacrBean should be used to filter data.
	 * @return
	 */
	Iterable<B> getData(int start, int size, boolean listAll, SortInfo sortInfo, Map<String,Object> smap);
	
	/**
	 * Returns the number of records.
	 * 
	 * @param smap Map to be used for filtering the results
	 * @param sortInfo which column should be used for ordering data.
	 * @return Returns the number of records.
	 */
	int getSize(SortInfo sortInfo, Map<String,Object> smap); 
	
	
	/**
	 * Can be used to detach any heavy resources that where created while
	 * finding the data produced by the query. Detach will always be called  
	 * after getData() and getSize() methods have been both executed.
	 */
	void detach();

	/**
	 * 删除整个collection
	 * */	
	void drop();
	
	
	Collection<B> batchImport(byte[] data) throws Exception;
	
	Collection<BaseOption> getOptions(Query query);
	
}
